import { CircleParser } from "./units/circleparser";
import { UseParser } from "./units/useparser";
import { LineParser } from "./units/lineparser";
import { PolygonParser } from "./units/polygonparser";
import { RectParser } from "./units/rectparser";
import { PathParser } from "./units/pathparser";
var SVGUnitParserFactory = {}
SVGUnitParserFactory.parse = function (mainEle,isParseSymboUnit,svgHeight) {
    let eleTagName = mainEle.tagName;
    let unitParser = this.getUnitParser(eleTagName);
    let unitGraph = null;
    if (unitParser) {
        unitParser.symbolUnitFlag = isParseSymboUnit;
        unitParser.svgHeight = svgHeight;
        unitGraph = unitParser.parse(mainEle);
    }
    unitParser = null;
    return unitGraph;
}

SVGUnitParserFactory.getUnitParser = function (eleTagName) {
    let unitParser = null;
    switch (eleTagName) {
        case 'circle':
            unitParser = new CircleParser();
            break;

        case 'use':
            unitParser = new UseParser();
            break;

        case 'line':
            unitParser = new LineParser();
            break;

        case 'rect':
            unitParser = new RectParser();
            break;

        case 'polygon':
            unitParser = new PolygonParser();
            break;

        case 'path':
            unitParser = new PathParser();
            break;

        default:
            break;
    }
    return unitParser;
}

export { SVGUnitParserFactory }